<%= error_messages_for 'time_log' %>
<!--[form:time_log]-->
<%=javascript_include_tag "dselect"%>

<table class="input">
<tr><td> </td>
   <td> 
    <%=radio_button "time_log","after_work_time","0"%><%='work time'.t%>
    <%=radio_button "time_log","after_work_time","1"%><%='after work time'.t%>
   </td>
   <td class="user" align=right><%=hidden_field :time_log,:project_id,:value=>params[:project_id]%> <%=@user.name%></td>
 </tr>
<tr>
<td width=20%><%='Todo'.t%></td><td colspan=2>
<%=radio_button_tag "related_todo",false,(@time_log.todo_id.to_i>0 ? false : true),:onclick=>"Element.hide('todo_select')"%><%="Unrelated Todo".t%>
<%=radio_button_tag "related_todo",true,(@time_log.todo_id.to_i>0 ? true : false),:onclick=>"Element.show('todo_select')"%><%="Related with Todo".t%>
<span id='todo_select' style="display:<%=(@time_log.todo_id.to_i>0 ? "on" : "none")%>">
  <script>
    var todoSelect = new DynamicOptionList();
    todoSelect.addDependentFields('todo_id','todo_item_id');
    <%@todos.each do |todo|%>
      <%todo.my_todo_items.each do |todo_item|%>
        todoSelect.forValue('<%=todo.id%>').addOptionsTextValue('<%=todo_item.name%>','<%=todo_item.id%>');
      <%end%>
    <%end%>
	<%if @time_log.todo_item_id.to_i > 0%>
	todoSelect.forField("todo_id").setValues("<%=@time_log.todo_id%>");
	todoSelect.forValue('<%=@time_log.todo.id%>').setDefaultOptions('<%=@time_log.todo_item_id%>');
	<%end%>
    todoSelect.printOptions();
  </script>
<select name=todo_id>
  <%=options_from_collection_for_select(@todos,:id,:name,@time_log.todo_id)%>
</select>
<select name=todo_item_id>
</select>
</span>
</td>
</tr>
<tr><td class=start><%='Timelog date'.t%>:</td>
<td colspan=2>
<script type="text/javascript"> _translations = { "OK": "OK", "Now": "Now", "Today": "<%="Today".t%>" }; Date.weekdays = $w("0 1 2 3 4 5 6"); Date.months = $w("<%="Jan".t%> <%="Feb".t%> <%="Mar".t%> <%="Apr".t%> <%="May".t%> <%="Jun".t%> <%="Jul".t%> <%="Aug".t%> <%="Sep".t%> <%="Oct".t%> <%="Nov".t%> <%="Dec".t%>"); </script>
<%=calendar_date_select_tag "time_date",@time_date,:buttons=>false%>
</td>
</tr>
<tr>
<td class="end"><%='Start - End'.t%>:</td>
<td colspan=2>
<table class='frame'><tr><td>
<%=text_field_tag "start_at",@start_time,:size=>'8',:onclick=>"selectTime(this,start_at)",:onblur=>"validateDatePicker(this)"%>
</td><td>
<%=link_to image_tag("time_picker/timepicker.gif",:border=>0),"#",:onclick=>"selectTime(this,start_at)"%>
</td><td width=20 align=center>
  -  
 </td><td>
<%=text_field_tag "end_at",@end_time,:size=>'8',:onclick=>"selectTime(this,end_at)",:onblur=>"validateDatePicker(this)"%>
 </td><td>
<%=link_to image_tag("time_picker/timepicker.gif",:border=>0),"#",:onclick=>"selectTime(this,end_at)"%>
 </td></tr></table>
</td>
</tr>

<tr><td><%='Work desc'.t%></td>
<td colspan=2><%= text_area 'time_log', 'work_desc'%></td></tr>
</table>
<!--[eoform:time_log]-->

